unit uFrmChangePassword;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Oracle, gnugettext, umainutils;

type
  TfrmChangePassword = class(TForm)
    edt_Pass1: TEdit;
    edt_Pass2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    btn_OK: TButton;
    btn_Cancel: TButton;
    procedure btn_OKClick(Sender: TObject);
    procedure btn_CancelClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    m_UserId: string;
    { Private declarations }
  public
    procedure ShowChangePassForm(UserId: string);
    { Public declarations }
  end;

var
  frmChangePassword: TfrmChangePassword;

implementation

uses uFrmMain;
{$R *.dfm}

procedure TfrmChangePassword.btn_CancelClick(Sender: TObject);
begin
  close;
end;

procedure TfrmChangePassword.btn_OKClick(Sender: TObject);
begin
  if edt_Pass1.Text = edt_Pass2.Text then
  begin
    UpdateDataToDB('USERS', 'PASSWORD=' + '''' + edt_Pass1.Text + '''', 'ID=' + m_UserId);
    close;
  end
  else
  begin
    MessageDlg(_('Password not equal!'), mtWarning, [mbOK], 0);
  end;
end;

procedure TfrmChangePassword.FormCreate(Sender: TObject);
begin
  gnugettext.TranslateComponent(self);
end;

procedure TfrmChangePassword.FormKeyPress(Sender: TObject; var Key: Char);
begin
  // The Escape key is #27.
  if Key = #27 then
    close;
end;

procedure TfrmChangePassword.ShowChangePassForm(UserId: string);
begin
  m_UserId := UserId;
  ShowModal();
end;

end.
